#include<iostream>
#include<memory>
#include"udpserver.hpp"
#include"Dict.hpp"
using namespace std;

string defaulthandler(const string& msg)
{
    string hello = "hello ";
    return hello + msg;
}

int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        cerr<<"Usage: ./udpclient port"<<endl;
        return 1;
    }
    uint16_t port=stoi(argv[1]);

    Enable_Console_Log_Strategy();

    Dict dict;
    dict.LoadDict();
    
    unique_ptr<UdpServer> udpserver = make_unique<UdpServer>
    (port,[&dict](const string& word,InetAddr &client)->string
    {
        return dict.Translate(word,client);
    });
    udpserver->Init();
    udpserver->Start();
    return 0;
}